package cn.school.student.service.impl;

import cn.school.student.dao.ExamResultDao;
import cn.school.student.service.ExamResultService;
import cn.school.student.vo.ResultVO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ExamResultServiceImpl extends ServiceImpl<ExamResultDao, ResultVO> implements ExamResultService,IService<ResultVO> {

    @Resource
    private ExamResultDao examResultDao;

    @Override
    public void batchAddResult(List<ResultVO> resultVOList) {
        saveBatch(resultVOList);
    }

    @Override
    public int addResult(ResultVO resultVO) {
        return this.baseMapper.insert(resultVO);
    }

    @Override
    public List<ResultVO> selectResultByExamId(String examId) {
        return examResultDao.selectResultByExamId(examId);
    }

    @Override
    public void batchUpdateResult(List<ResultVO> resultVOList) {
        updateBatchById(resultVOList);
    }

    @Override
    public int deleteByExamId(String id) {
        LambdaUpdateWrapper<ResultVO> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(ResultVO::getExamId,id);
        return this.baseMapper.delete(wrapper);
    }
}
